window.onload=function(){
	$(".devicelist").css("backgroundColor","#50855B").siblings().css("backgroundColor","#101113");
	//查询水机状态下拉框
	$(".deviceStatusCheckBox").click(function(event){
		event.stopPropagation();
		$(".deviceStatusCheckDropBox").show();
		$(".deviceStatusCheckDropBox a").unbind('click').click(function(){
			$(".deviceStatusCheckBox").val($(this).html());
			$(".deviceStatusCheckDropBox").hide();
		});
		$("body").unbind('click').click(function(){
			$(".deviceStatusCheckDropBox").hide();
		});
	});
	//查询设备类型下拉框
	var type_id='';
	$(".deviceModelBox").click(function(event){
		event.stopPropagation();
		$(".deviceModelDropBox").show();
		$(".deviceModelDropBox a").unbind('click').click(function(event){
			event.stopPropagation();
			$(".deviceModelBox").val($(this).children("span").html());
			$(".deviceModelDropBox").hide();
			$("body").unbind('click').click(function(){
				$(".deviceModelDropBox").hide();
			});
			type_id=$(this).children("input").val();
		});
	});
	//搜索
	$(".searchList > a").click(function(){
		if(type_id==''){
			type_id=$(".typeId").val();
		}
		var device_code = $(".deviceCodeBox").val();
		var status = $(".deviceCheckBox").val();
		if(device_code=="%"){
			hint("非法输入，请正确输入编号！");
		}else{
			window.location.href='/admin/device/index?device_code='+device_code+'&status='+status+'&type_id='+type_id;
		}
	});
	//根据绑定用户获取用户信息
	$(".bindUser a").click(function(){
		$.ajax({
			url:"/admin/api/user/customer",
			type:"get",
			dataType:"json",
			data:{
				name:$(this).html()
			},
			success:function(data){
				console.log(data);
				if(data.status.errCode==0){
					$(".userName").html(data.data.customer.name);
					$(".userPhone").html(data.data.customer.phone);
					$(".IDNum").html(data.data.customer.id_number);
					$(".address").html(data.data.customer.installation_address);
				}else{
					hint(data.status.message);
				}
			}
		})
		$(".userInfo").show();
		$(".userInfOkBtn").unbind('click').click(function(){
			$(".userName").html("");
			$(".userPhone").html("");
			$(".IDNum").html("");
			$(".address").html("");
			$(".userInfo").hide();

		});
	});
}